﻿#region Using Statements

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using MilwormsGameData;

#endregion

namespace MilwormsGameContentPipeline
{
    [ContentTypeWriter]
    public class CharacterWriter : MilwormsGameWriter<Character>
    {
        WorldObjectWriter worldObjectWriter = null;

        protected override void Initialize(ContentCompiler compiler)
        {
            worldObjectWriter = compiler.GetTypeWriter(typeof(WorldObject))
                as WorldObjectWriter;

            base.Initialize(compiler);
        }

        protected override void Write(ContentWriter output, Character value)
        {
            output.WriteRawObject<WorldObject>(value as WorldObject, worldObjectWriter);

            output.Write(value.MapIdleAnimationInterval);
            output.WriteObject(value.MapSprite);
            output.Write(value.MapWalkingAnimationInterval);
            output.WriteObject(value.WalkingSprite);
        }

        public override string GetRuntimeType(TargetPlatform targetPlatform)
        {
            return typeof(MilwormsGameData.Character).AssemblyQualifiedName;
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(MilwormsGameData.Character.CharacterReader).AssemblyQualifiedName;
        }
    }
}
